﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

public class XiuXingModel : SingletonTemplate<XiuXingModel>
{
    public static class ConstsNames
    {
        public const string LEVEL = "XiuXingModel.Lvel";
        public const string CHAPTER = "XiuXingModel.Chapter";
    }

    public int curLevel;
    public int curChapter;

    public void Init()
    {
        curLevel = PlayerPrefs.GetInt(ConstsNames.LEVEL, 1);
        curChapter = PlayerPrefs.GetInt(ConstsNames.LEVEL, 1);
    }

    public void SetSuccess(int chapter, int level)
    {
        if (chapter > curChapter || chapter == curChapter && level > curLevel)
        {
            SetChapter(chapter);
            SetLevel(level);
        }
    }

    public void SetLevel(int v)
    {
        curLevel = v;
        PlayerPrefs.SetInt(ConstsNames.LEVEL, v);
    }

    public void SetChapter(int v)
    {
        curChapter = v;
        PlayerPrefs.SetInt(ConstsNames.CHAPTER, v);
    }
}
